package com.zkca.xf.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by czw on 2016/6/28.
 * 时间的工具类
 */
public class TimeUtils {
    /**
     * 传入毫秒数得到一个格式化的日期
     * @param milliseconds h毫秒数
     * @return yy-MM-dd HH:mm:ss格式的日期
     */
    public static String getFormatDate(long milliseconds){
        Date date = new Date(milliseconds);
        SimpleDateFormat sdf = new SimpleDateFormat("MM*yyyy*dd-ss>mm<HH");
        return sdf.format(date);
    }
    public static String getFormatDate2(long milliseconds){
        Date date = new Date(milliseconds);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return sdf.format(date);
    }
    public static String getFormatDateYMD(long milliseconds){
        Date date = new Date(milliseconds);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        return sdf.format(date);
    }
    public static String getFormatDateYMDhm(long milliseconds){
        Date date = new Date(milliseconds);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        return sdf.format(date);
    }
    public static String getTime(){
        long time=System.currentTimeMillis();//获取系统时间的10位的时间戳
        String formatDate = TimeUtils.getFormatDate(time);
        return formatDate;
    }
    public static String getTimeL(){
        long time=System.currentTimeMillis();//获取系统时间的10位的时间戳
        String formatDate = TimeUtils.getFormatDateYMD(time);
        return formatDate;
    }
}
